$(function(){ 
$(".take_start input[type=button]").click(function(e){ 
e.preventDefault();
	$(".body_div_animate:first").animate({ 
	opacity:0,
	top : '-'+$(".body_div_animate:first").height()		 
    },300);
	  
	  
	  
	   $(".body_div_animate:eq(1)").css({ 
		 display : 'block',
		 top : $(window).height()+'px'}); 
		 $height =  $(window).height()/2;
$less =  $(".body_div_animate:eq(1)").height()/2;
$h = $height - $less;	   
	   $(".body_div_animate:eq(1)").delay(100).animate({
		    top : $h+"px",
			opacity: 1 
	   	
	   },300)
	});
  
});  



$(".multimedia_option a").live('click',function(e){  
/********************************************/
$.post("add_to_tamp.php",{cat:$(this).attr("id")},function(data){});
/********************************************/
e.preventDefault();
$(".body_div_animate:eq(1)").animate({ 
	opacity:0,
	top : '-'+$(".body_div_animate:eq(1)").height()		 
    },300);
      $(".body_div_animate:eq(2)").css({ 
		 display : 'block',
		 top : $(window).height()+'px'}); 
		 $height =  $(window).height()/2;
$less =  $(".body_div_animate:eq(2)").height()/2;
$h = $height - $less;

	   
	   $(".body_div_animate:eq(2)").delay(0).animate({
		    top : $h+"px",
			opacity: 1 
	   	
	   })
}); 
 

 


$(".bt2 input[type=button]").live('click',function(e){
	$langth  =  $("#business_url").val().length;
if($langth>6){  

$.post("add_to_tamp.php",{display:$("#business_url").val()},function(data){ 

 if (data!='1'){ 
 $.post("add_to_tamp.php",{business_url:$("#business_url").val()},function(data){ });
  $(".body_div_animate:eq(2)").animate({ 
	opacity:0,
	top : '-'+$(".body_div_animate:eq(2)").height()		 
    },300)	   
	    $(".body_div_animate:eq(3)").css({ 
		 display : 'block',
		 top : $(window).height()+'px'}); 
		 $height =  $(window).height()/2;
$less =  $(".body_div_animate:eq(3)").height()/2;
$h = $height - $less;

	   
	   $(".body_div_animate:eq(3)").delay(0).animate({
		    top : $h+"px",
			opacity: 1 
	   	
	   })
	   

 }


});  
}






else { $(".alerti").fadeIn();  return false; }
}); 
 
 
 
 
 
 $(".topnav input[type=button]#login").live("click",function(){ 
  $(".overly").fadeIn();
    $(".popupmain").fadeIn();
  
 
 })
 
 
  
 $(".head a").live("click",function(e){ 
  
  $(".overly").fadeOut();
    $(".popupmain").fadeOut();
  
 
 })

function removeSpaces(string) {
 return string.split(' ').join('-');
}
$("#business_url").live("keyup",function(e){ 
$langth  =  $(this).val().length;
if($langth>6){
	var str=$("#business_url").val();
	str1 = removeSpaces(str);
	$("#business_url").val(str1);
	$.post("add_to_tamp.php",{display:str1},function(data){ //alert(data);
			if(data==1){//alert('This Display Name Already Register Please try other name!!');
					
					$("#msg").html("<span style='color:red;'>This Url Already Register Please Try Other!</span>");
					
					$("#msg").addClass('error');
					document.getElementById("business_url").focus();  return false; 
			}else{
				$("#msg").html("<span style='color:green;'>http://www.mycitydial.com/"+str1+"</span>");
			}		
		});
	
}else{$("#msg").html("<span style='color:red;'>Url must be grater then six Character!</span>");}
});






$(".tab_name input[type=text]").live("blur",function(){ 
 
});


function setwindow (obj) { 
$height =  $(window).height()/2;
$less =  $(".body_div_animate:visible").height()/2;
$h = $height - $less;
if (obj=='css'){
$(".body_div_animate").css("top",$h+"px");
}
else { 
$(".body_div_animate").stop(true,true).animate({ top : $h+"px" });
}
}



$(function(){ 
$(".body_div_animate:gt(0)").css( { opacity : 0,  
   display : 'none' });
setwindow('css');
})

$(window).resize(function(){ 
setwindow('ani');
})



$(function(){ 
$(".hide_layer_bt a").click(function(){
$top  = $(".hide_layer_main").css("marginTop");
$top  = parseInt($top);
$top  =  ($top==0)?-35 :0 ; 

$(".hide_layer_main").animate({ marginTop: $top },200)



  })
});

//dashboard animation

 
	

 


//dashboard animation end



$(function(){ 

$(".element").hover(
  function () {
    $(this).find(".hovertip").stop(true,false).animate({ bottom : 0 },150);
  },
  function () {
    $(this).find(".hovertip").stop(true,false).animate({ bottom : -148 },150);
  }
);
});




$(function(){ 
 $("#business_url").keydown(function(e){ 
 var code = (e.keyCode ? e.keyCode : e.which);
 if(code == 13) {  
    $(".bt2 input[type=button]").click();	
	return false;
 }
 })
})

/**********************************************
var currenttime = $.now();
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var serverdate=new Date(currenttime)

function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}

function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear()
var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds())
document.getElementById("servertime").innerHTML=timestring;
document.getElementById("serverdate").innerHTML=datestring;
}

window.onload=function(){
	displaytime();
setInterval("displaytime()", 1000)
}
*********************************************/





$(function(){ 
 //$(".steps ul li:first a").addClass("current");
 
 $(".add_url_bt input[type=image]").click(function(){ 
  $("#output2 li").fadeOut();
    $("#output2 li:eq(1)").fadeIn();
	$(".steps li a").removeClass('current');
	$(".steps li:eq(1) a").addClass('current');	
	
     
 })
 
 
 

})










//new added
function publish(obj){ 
	$.post("add_to_tamp.php",{status:obj},function(data){ 
		if(data==1){ alert("Your Url Suscessfully Activated");
		}else{alert("Your Url Suscessfully Deactivated");}
	});
}


$(document).ready(function() { 		
$('#photoimg').live('change', function(){ 
$(".loadgif").fadeIn(0);
 

 $("#imageform").ajaxForm({
 target: '.photo_gallery' , success:  function(){$(".loadgif").fadeOut(0);}  }).submit();

  });

})


$("#gallery_title").live('blur',function(e){ //alert($("#gallery_title").val().length);
if($("#gallery_title").val().length>5){
	$.post("add_to_tamp.php",{gallery_title:$("#gallery_title").val().length},function(data){ //alert(data);
		if(data==1){ $("#gallery_title").css("border","1px solid green"); }
	});
}
});

$(".alt_text").live('blur',function(e){alert($(".alt_text").closest("div.photo_select input").val());
if($("#gallery_title").val().length>5){
	$.post("add_to_tamp.php",{gallery_title:$("#gallery_title").val().length},function(data){ //alert(data);
		if(data==1){ $("#gallery_title").css("border","1px solid green"); }
	});
}

});



$(".alt_txt").live('click',function(e){//
$(this).hide();
$(this).parent().find('input').show().focus();
});

function deleteimg(str,obj){ //alert(obj);
	str.src = 'images/loader.gif';
	$.post("add_to_tamp.php",{deleteimg:obj},function(data){ //alert(data);
		$(str).closest('section').fadeOut();
	});
}
function save_alt_text(str,obj,id){// alert(obj);
	$.post("add_to_tamp.php",{save_alt_text:obj,id:id},function(data){ //alert(data);
		if(data==1){ alert(data);//$(str).css("border","1px solid green"); 
		}
	});
}

//new added end




////////////for business page
function validate_url(){ 
	$langth  = $("#business_url").val().length;
	if($langth>6){//alert($("#business_url").val().length);
		var str=$("#business_url").val();
		str1 = removeSpaces(str);
		$("#business_url").val(str1);
		$.post("add_to_tamp.php",{display:str1},function(data){ alert(data);
				if(data==1){//alert('This Display Name Already Register Please try other name!!');
						
						$("#msg").html("<span style='color:red;'>This Url Already Register Please Try Other!</span>");
						
						$("#msg").addClass('error');
						document.getElementById("business_url").focus();  return false; 
				}else{
					$("#msg").html("<span style='color:green;'>http://www.mycitydial.com/"+str1+"</span>");
				}		
			});
		
	}else{$("#msg").html("<span style='color:red;'>Url must be grater then six Character!</span>"); return false;}
}
////////////////////////////////////////////////////////////
//////to create session on skip/////////////////////////////
function add_session(){//alert("ok");
	$.post("add_to_tamp.php",{session:1},function(data){ });
}

//////preview url on blur/////////////////////////////////////
$("#page_url,#height").live('blur',function(e){ //alert($("#page_url").val());
	
	$url = $("#page_url").val();
	var pattern = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
        if (pattern.test($url)) { 
        $url = $url;
        } 
		else { 
		$url = "http://"+$url
		}
		
 
	
	myiframe.location.href = $url;
	$('#myiframe').css('height', $("#height").val()+'px');
});
/////////////////////////////////////////////////////////////
///////////

 


$(".tabpanel li a").live("click",function(e){ 
 e.preventDefault();
 $i = $(".tabpanel li a").index(this);
  $(".tabpanel li a").removeClass("active");
   $(this).addClass("active"); 
 $(".outbox .outboxin").fadeOut(100);  
 $(".outbox .outboxin:eq("+$i+")").fadeIn(100);     
})





$(function(){ 
 $("#fanpage1").click(function(){ 
   $(".cpage:visible").submit(); 
 })
})



$("#btnstep2").live("click",function(e){ 
 e.preventDefault();
  if ( $.trim($("#gallery_title").val())=='')
  { 
  $("#gallery_title").addClass('error')
   	 e.preventDefault();
  }
  else { 
   $("#step2").submit();
  }
  
});




$(function(){ 
$("input[name=alt_text]").live('blur',function(){  
    $val = $(this).val();
	$id = $(this).attr('title');//alert($id);
 
 	$.post("add_to_tamp.php",{alt_txt:$val,id:$id},function(data){ 
	});
	
	
   $(this).css('display','none');   
   $(this).parent().find('p').text($val).css('display','block');

    
});});




$("#btnstep3").live("click",function(e){
	e.preventDefault(); 
    $var = $("iframe").contents().find('body').text();
    $(".artical_name_box").removeClass('error');
    if ( $.trim($var)==''){ 
	 $(".alerti").fadeIn();
	 return false;
	}
      
	else { 
	 $("form").submit();
	}  
  
 
  
  
  
  
   
  
});





$("#btnstep4, #about_form input[type=submit]").live("click",function(e){  
$('.error,.errorc').removeClass('error');    
   
 $v1 = $("input[name=title]");
 $v2 = $("textarea.tips_area");  
 $v3 = $("input[name=email]");
  if ($.trim($v1.val())=='')
  { 
  $v1.addClass('error').focus();
  return false;
  } 

  if ($.trim($v2.val())=='')
  { 
  $v2.addClass('error').focus();
  return false;
  } 
 
   email_regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i;
   if(!email_regex.test($v3.val())){ 
    $v3.addClass('error').focus();     
   return false;    
    }
    if(!$('input[type="checkbox"]').is(':checked'))
	{ 
     $('.agree').addClass('errorc').focus();     
    return false;    
    }
  else { 
  $("#about_form").submit();  
  }

});



$(function(){ 
 $.getScript("js/jquery.twitter.js",function(){ 
$("#twitter").getTwitter({
					userName: "jquery",
					numTweets: 3,
					loaderText: "Loading tweets...",
					slideIn: true,
					slideDuration: 750,
					showHeading: true,
					headingText: "Twitter@",
					showProfileLink: false,
					showTimestamp: true,
					includeRetweets: false,
					excludeReplies: true
				});
 })
})




 
$(function(){ 
				$("a[rel^='prettyPhoto']").prettyPhoto();

$.getScript("js/slider.js", function() {
	

$size = $(".slider ul li").size();
if($size>3){	
	
	
$(".slider").jCarouselLite({
		vertical: false,
		hoverPause:true,
		visible: 4,
		auto : 1000000,
		btnNext : ".nextprev a.next",
		btnPrev : ".nextprev a.prev",		
		speed:500
	});}
 
});

 
$("a.laro").click(function(){ 
 if ($(this).is(".active")){  
 $(this).removeClass("active"); 
  $(".copytext").slideUp(); 
  $(".contant").fadeIn(0);
 $(".morelink").click();
 $(this).find("img").attr("src","images/rarrow.jpg") 
 }
 else{  
  $(this).addClass("active"); 
 $(".copytext").slideDown();$(".contant").fadeOut(0);
  $(this).find("img").attr("src","images/larrow.jpg")
   $(".morelink").click();
  } 
})



 })



$(document).ready(function() {
	var showChar = 300;
	var ellipsestext = "";
	var moretext = "";
	var lesstext = "";
	$('.more').each(function() {
		var content = $(this).html();

		if(content.length > showChar) {

			var c = content.substr(0, showChar);
			var h = content.substr(showChar-1, content.length - showChar);

 			var html = c + '<span class="moreelipses">'+ellipsestext+'</span>&nbsp;<span class="morecontent"><span>' + h + '</span>&nbsp;&nbsp;<a href="" class="morelink">'+moretext+'</a></span>';

			$(this).html(html);
		}

	});

	$(".morelink").click(function(){
		if($(this).hasClass("less")) {
			$(this).removeClass("less");
			$(this).html(moretext);
		} else {
			$(this).addClass("less");
			$(this).html(lesstext);
		}
		$(this).parent().prev().toggle();
		$(this).prev().toggle();
		return false;
	});
	   $(".morelink").click();
});


$("#gallery_title").live("click focus",function(){ 
 $val = $(this).val();
 if ($val=='Enter Your gallery name'){ 
 $(this).val('');
 }
 
})



$("#gallery_title").live("blur",function(){ 
 $val = $(this).val();
 if ($val==''){ 
 $(this).val('Enter Your gallery name');
 }
 
})
 


$(".artical_name .artical_name_box").live("click focus",function(){
 $this = $(this);
 
 if (  $this.val() =='Write your Article Title Here!')
 { 
  $this.val('');
 }
	
	})

$(".artical_name .artical_name_box").live("blur",function(){
 $this = $(this);
 
 if (  $this.val() =='')
 { 
  $this.val('Write your Article Title Here!');
 }
	
	})



/////////Edit Url/////////////////
$("#url input[type=text]").live("keyup",function(e){ 
	$langth  = $("#url input[type=text]").val().length;
	if($langth>6){
		var str=$("#url input[type=text]").val();
		str1 = removeSpaces(str);
		$("#url input[type=text]").val(str1);
	}else{
		$("span#msg").html("Url must be grater then six Character!");
	}
});
	
$("a#urledit").live("click",function(){
    $("#url h1 span").fadeOut(0);
    $("#url input[type=text]").fadeIn(0);  
	$(this).addClass("active").html("Done");	
})


 


$("a#urledit.active").live("click",function(){
 
 

$.ajax({
        type: "POST",
        url: 'add_to_tamp.php',
        data: {
          url : $("#url input[type=text]").val(), 
		  urlid : $("#urlid").val(),
        }, 
        success: function (response) {
        if (response==0)
		{ 
		$(".navalible").remove();
			$("#url h1 span").fadeIn(0).text("http://www.mycitydial.com/"+$("#url input[type=text]").val());
			$("#url input[type=text]").fadeOut(0);  
			$("a#urledit.active").removeClass("active").html("+Edit");	 
		}
		
		else { 
		$(".navalible").remove();		
		 $("a#urledit.active").after("<div class='navalible'>Not Avalable<div>");
		}
     	}
		})
})


$("input[name=urltype]").live("click",function(){ 
 $i = $("input[name=urltype]").index(this);
  if ($i==0){ 
   $(".cpage").hide();
   $(".cpage:first").show();
    $("#myiframe").show();
   $("#myimage").hide();     
}else{ 
   $(".cpage").hide();
   $(".cpage:last").show(); 
   $("#myiframe").hide();
   $("#myimage").show(); 
  }
  
  
  
    
 
 
})


$(".urlupload a").live("click",function(){  
 $(this).parent().find("input[type=file]").click();

})

$(".urlupload input[type=file]").live("change",function(){  
 
 $("input[name=photourl]").val($(this).val());
 
   

})


 
function readURL(input) {
	if (input.files && input.files[0]) {
		var reader = new FileReader();
		reader.onload = function(e){ $('#myimage').attr('src', e.target.result)};
		reader.readAsDataURL(input.files[0]);
	}
}

